﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PathesHelper.cs" company="Elilink">
//   Defor
// </copyright>
// <summary>
//   Helper class to fix user-editable pathes
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace BusinessLayer.Tools
{
    /// <summary>
    ///     Helper class to fix user-editable paths
    /// </summary>
    public class PathesHelper
    {
        #region Public Methods and Operators

        /// <summary>
        /// Fixes the path to logs folder.
        /// </summary>
        /// <param name="currentPath">
        /// The current path.
        /// </param>
        /// <param name="createSubFolder">
        /// if set to <c>true</c> will add additional DeploymentLogs\ string as a subfolder.
        /// </param>
        /// <returns>
        /// Fixed path.
        /// </returns>
        public static string FixLogsPath(string currentPath, bool createSubFolder)
        {
            if (string.IsNullOrEmpty(currentPath))
            {
                return string.Empty;
            }

            string fixedPath = currentPath.EndsWith("\\") ? currentPath : string.Concat(currentPath, "\\");

            return createSubFolder ? string.Concat(fixedPath, "DeploymentLogs\\") : fixedPath;
        }

        /// <summary>
        /// Fixes the path to solution folder.
        /// </summary>
        /// <param name="currentPath">
        /// The current path.
        /// </param>
        /// <returns>
        /// Fixed path.
        /// </returns>
        public static string FixSolutionPath(string currentPath)
        {
            if (string.IsNullOrEmpty(currentPath))
            {
                return string.Empty;
            }

            return currentPath.EndsWith("\\") ? currentPath : string.Concat(currentPath, "\\");
        }

        #endregion
    }
}